package com.studentstreet.tools;

import android.content.Context;
import android.text.Html;
import android.text.Spanned;

import com.studentstreet.R;

/**
 * @author likebamboo
 * 
 */
public class HtmlTools {
	// 商品名和所属商家。 格式化TextView的字体，使之显示不同颜色字体
	public static Spanned getGoods(String name, String seller) {
		name = "<b><font color='red'>" + name + "</font></b>";
		seller = "【<font color='#00bbaa'>" + seller + "</font>】";
		return Html.fromHtml(name + seller);
	}

	public static Spanned getOrderGoods(Context context, String name,
			String seller, int state) {
		String[] orderState = context.getResources().getStringArray(
				R.array.order_state);
		name = "<b><font color='red'>" + name + "</font></b>";
		seller = "【<font color='#00bbaa'>" + seller + "</font>】";
		String stateStr = "-<font color='#828282'>" + orderState[state]
				+ "</font>";
		return Html.fromHtml(name + seller + stateStr);
	}

	// 商品价格。 格式化TextView的字体，使之显示不同颜色字体
	public static Spanned getPrice(Context context, String price) {
		price = "<b><font color='red'>￥" + price + "</font></b>";
		String html = context.getResources().getString(R.string.goods_price,
				price);
		return Html.fromHtml(html);
	}

	// 商品销售量。 格式化TextView的字体，使之显示不同颜色字体
	public static Spanned getCount(Context context, String count) {
		count = "<b><font color='red'>" + count + "</font></b>";
		String html = context.getResources().getString(
				R.string.goods_saleCount, count);
		return Html.fromHtml(html);
	}

	// 商品所属商家。 格式化TextView的字体，使之显示不同颜色字体
	public static Spanned getSeller(Context context, String seller) {
		seller = "<b><font color='#00bbaa'>" + seller + "</font></b>";
		String html = context.getResources().getString(R.string.goods_seller,
				seller);
		return Html.fromHtml(html);
	}

	// 商品类别。 格式化TextView的字体，使之显示不同颜色字体
	public static Spanned getClass(Context context, String className) {
		className = "<b><font color='#00bbaa'>" + className + "</font></b>";
		String html = context.getResources().getString(R.string.goods_class,
				className);
		return Html.fromHtml(html);
	}

	// 商品统计信息
	public static Spanned getInfo(Context context, int resId, Object... params) {
		for (int i = 0; i < params.length; i++) {
			params[i] = "<b><font color='red'>" + params[i] + "</font></b>";
		}
		String html = context.getResources().getString(resId, params);
		return Html.fromHtml(html);
	}

	// 订单跟踪界面订单信息
	public static Spanned getOrderNo(Context context, String orderNo, int state) {
		String html = "<font color='#828282'>订单号：</font><b><font color='red'>"
				+ orderNo + "</font></b>";
		return Html.fromHtml(html);
	}

	// 订单跟踪界面 送货地址 信息
	public static Spanned getOrderAddr(Context context, String addr) {
		addr = "<b><font color='#828282'>" + addr + "</font></b>";
		String html = context.getResources().getString(R.string.track_addr,
				addr);
		return Html.fromHtml(html);
	}

	// 订单跟踪界面 收餐人 信息
	public static Spanned getOrderUser(Context context, String user) {
		user = "<b><font color='#828282'>" + user + "</font></b>";
		String html = context.getResources().getString(R.string.track_user,
				user);
		return Html.fromHtml(html);
	}

	// 订单跟踪界面 统计 信息
	public static Spanned getOrderTotal(Context context, String price,
			String count) {
		price = "<b><font color='red'>" + price + "</font></b>";
		count = "<b><font color='red'>" + count + "</font></b>";
		String html = context.getResources().getString(R.string.track_total,
				price, count);
		return Html.fromHtml(html);
	}
	//
	// toUser.setText("收餐人：" + order.getToUser());
	// toAddr.setText("地址：" + order.getToAddr());
	// double price = 0d;
	// int count = 0;
	// for (CartEntity cart : orderList.get(groupPosition).getCartList()) {
	// price += cart.getCart_price() * cart.getCart_count();
	// count += cart.getCart_count();
	// }
	// total.setText("总价格：" + price + "  ;  总数量：" + count);

}
